package com.chenjt.netty.thirteen_handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

/**
 * 注释：
 *
 * @author chenjt
 * @date 2024/9/7 9:30
 */
public class MyByteToLongReplayingDecoder extends ReplayingDecoder<Void> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        System.out.println("MyBateToLongReplayingDecoder decode invoked!");

        /**
         * 和直接继承ByteToMessageDecoder相比，
         * 这里不用判断可读字节是否>=8，Netty底层会自己去做判断
         */
        out.add(in.readLong());
    }
}
